home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / JUSTIFY.DMO < prev    next >
Text File  |  1996-07-04  |  3KB  |  78 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   JUSTIFY .DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18. '.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
  19. ' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
  20.  
  21. $INCLUDE "DAS-NB01.INC"
  22. COLOR 7,0
  23. CLS
  24.  
  25. ? "┌─────────────────────────────────────────────────────────────────────────────
  26. ? "│ fJustify$ ( V$, MaxLen%, Which% )
  27. ? "├─────────────────────────────────────────────────────────────────────────────
  28. ? "│ This one you have to write yourself but it is quick and simple but provides
  29. ? "│ a very important service to any program that inputs data from the user.
  30. ? "│ All it does is call a series of justifying routines by number! Why? well, if
  31. ? "│ you assign your input fields with one of these numbers then it can call
  32. ? "│ whichever one you want (or your users choose) automatically. It really isn't
  33. ? "│ too user-friendly to make the user press <CAPS LOCK> just because you need
  34. ? "│ the data all in UCASE. PowerBASIC does it faster than the user anyhow!
  35. ? "│ eg:    the user inputs:  this is a test
  36. ? "│      the program wants: THIS IS A TEST
  37. ? "│      now you can either send the user an error message and make them
  38. ? "│      type it all over again or just UCASE it!
  39. ? "└─────────────────────────────────────────────────────────────────────────────
  40.  
  41. D$ = "This  is a   test."
  42. PRINT "The test string is: "; CHR$(34); D$; CHR$(34)
  43. PRINT
  44.  
  45. FOR Which% = 0 TO 4
  46.   PRINT CHR$(34); fJustify$( D$, 22, Which% ); CHR$(34)
  47. NEXT
  48.  
  49. FUNCTION fJustify$ ( BYVAL V$, BYVAL L%, BYVAL Which% ) LOCAL PUBLIC
  50.   LOCAL I$
  51.               I$  = fRemoveDBLspc$( V$ )        ' remove double spaces
  52.   SELECT CASE Which%
  53.     CASE 00 : I$ = fLRtrim$    ( I$ )
  54.     CASE 01 : I$ = fJustLeft$  ( I$, L%, 32 )
  55.     CASE 02 : I$ = fJustCenter$( I$, L%, 32 )
  56.     CASE 03 : I$ = fJustRight$ ( I$, L%, 32 )
  57.     CASE 04 : I$ = fJustRight$ ( I$, L%, 48 )   ' PAD LEFT W/ 0s
  58.   END SELECT
  59.   FUNCTION = I$
  60.  
  61. END FUNCTION
  62.  
  63. $if 0
  64.  
  65.   Try this idea for your input routines:
  66.  
  67.   TYPE MyInputTYPE
  68.     Row    AS BYTE     ' the row to input at
  69.     Col    AS BYTE     ' left most column
  70.     Length AS BYTE     ' maximum length of input
  71.     Style  AS BYTE     ' alpha, caps, numeric, etc.
  72.     Just   AS BYTE     ' final justification
  73.   END TYPE
  74.   DIM tI(20) AS MyInputTYPE
  75.   G$ = fInputAll$( tI(), D$() )   ' returns exiting key-press
  76.  
  77. $endif
  78.